package com.example.ssss.data;

import android.os.Message;

import androidx.lifecycle.MutableLiveData;

import com.example.ssss.entity.HistoryResponse;
import com.example.ssss.state.HistoryDetailViewModel;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class HttpRequestManager {

    private HttpRequestManager(){}
    private static HttpRequestManager httpRequestManager;
    public static HttpRequestManager getInstance(){
        if(null==httpRequestManager){
            synchronized (HttpRequestManager.class){
                if(null==httpRequestManager){
                    httpRequestManager=new HttpRequestManager();
                }
            }
        }
        return httpRequestManager;
    }


    //已改
    public void select(MutableLiveData<HistoryResponse> historyResponse,int index,String userid){

        new Thread(){
            @Override
            public void run() {
                super.run();
                final HistoryResponse[] historyResponse1 = new HistoryResponse[1];

                MysqlOperation sql = new MysqlOperation();
                sql.userDao=new MysqlOperation.UserDao();
                try {
                    historyResponse1[0] =sql.userDao.select(index,userid);
                    System.out.println("Mysql连接成功");
                    historyResponse.postValue(historyResponse1[0]);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }.start();
    }

//    public void selectHeart(MutableLiveData<HistoryResponse> historyResponse){
//
//        new Thread(){
//            @Override
//            public void run() {
//                super.run();
//
//                final HistoryResponse[] historyResponse1 = new HistoryResponse[1];
//                MysqlOperation sql = new MysqlOperation();
//                sql.heartDao=new MysqlOperation.HeartDao();
//                try {
//                    historyResponse1[0] =sql.heartDao.select("heart");
//                    System.out.println("Mysql连接成功");
//                    historyResponse.postValue(historyResponse1[0]);
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//
//            }
//        }.start();
//
//    }




}
